// magic 初始化调用

import { fileURLToPath } from 'node:url';
import path from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

import FastifyVite from '@fastify/vite';

export default async function(fastify, opts) {
  await fastify.register(FastifyVite, {
    root: path.join(__dirname, '_web-vue'),
    renderer: '@fastify/vue',
    dev: true, // TODO
    spa: true
  });
  await fastify.vite.ready();
  await fastify.get('/', (req, reply) => {
    return reply.html();
  });
};
